package com.lxl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lxl.entity.PageResult;
import com.lxl.mapper.StudentMapper;
import com.lxl.pojo.Student;
import com.lxl.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageResult allStudents(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        Page<Student> page=studentMapper.allStudents();
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public Integer addStudent(Student student) {
        return studentMapper.addStudent(student);
    }

    @Override
    public Integer delStudent(String stu_id) {
        return studentMapper.delStudent(stu_id);
    }

    @Override
    public Integer editStudent(Student student) {
        return studentMapper.editStudent(student);
    }

}
